﻿<%@ Page Title="Repair Jobs" Theme="POSSystem" Language="C#" MasterPageFile="~/EditPages/Popup.Master" AutoEventWireup="true" CodeBehind="ViewRepair.aspx.cs" Inherits="WebUI.EditPages.ViewRepair" %>

<%@ Register Src="~/Controls/POSControls/RepairListCtrl.ascx" TagName="RepairList" TagPrefix="uc" %>
<%@ Register Src="~/Controls/POSControls/CustomerCompactListCtrl.ascx" TagName="CustList" TagPrefix="uc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupHeadHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PopupToolbarHolder" runat="server">
    <script type="text/javascript">
        function loadRepairByCustID() {
            var custID = getSelectedItemID<%=lstCust.ClientID %>();
            document.getElementById("<%=btnLoadByCustID.ClientID %>").click();
        }

        function showSale(key){
            var w = screen.availWidth - 10;
            var returnValue = window.showModalDialog(key, '', 'dialogWidth=' + w + 'px;dialogHeight=600px;resizable=yes;help=no;unadorned=yes;');
            if(returnValue > 0){
                document.getElementById("<%=btnLoadAll.ClientID %>").click();
            }
            return false;
        }

        function showEditProblem(id){
            var returnValue = window.showModalDialog("<%= GetEditRepairProblemLink() %>" + '?id=' + id, '', 'dialogWidth=500px;dialogHeight=200px;resizable=yes;help=no;unadorned=yes;');
            if(returnValue > 0){
                document.getElementById("<%=btnLoadAll.ClientID %>").click();
            }
            return false;
        }

        function showChangeRepairBox(id, jobID){
            var returnValue = window.showModalDialog("<%= GetRepairBoxLink() %>" + '?id=' + id + '&jobID=' + jobID, '', 'dialogWidth=500px;dialogHeight=200px;resizable=yes;help=no;unadorned=yes;');
            if(returnValue > 0){
                document.getElementById("<%=btnLoadAll.ClientID %>").click();
            }
            return false;
        }

        function showUpdateStatus(id){
            var returnValue = window.showModalDialog("<%= GetUpdateStatusLink() %>" + "?id=" + id, "", 'dialogWidth=530px;dialogHeight=550px;resizable=yes;help=no;unadorned=yes;');
            if(returnValue > 0){
                document.getElementById("<%=btnLoadAll.ClientID %>").click();
            }
            return false;
        }

        function confirmBookout(){
            var id = HasCheckedItems<%=lstRepair.ClientID %>();
            if(id == false){
                alert("No item was selected!");
                return false;
            }

            var returnValue = window.showModalDialog("<%= GetConfirmReturnLink() %>", '', 'dialogWidth=530px;dialogHeight=100px;resizable=yes;help=no;unadorned=yes;');
            
            if(returnValue == 'yes'){
                return true;
            }

            if(returnValue == 'no'){
                document.getElementById("<%=btnReturnAsUnrepair.ClientID %>").click();
                return false;
            }

            return false;
        }
    </script>
    <asp:Panel ID="panelToolBar" runat="server" DefaultButton="btnSearchProduct">
        <table class="popuptoolbar" width="100%">
            <tr>
                <td style="vertical-align:middle; text-align:left">
                    <asp:LinkButton class="tblabel" ID="LinkBubttton1" runat="server" OnClientClick="return false;" >
                        <img src="Images/trans.png" /><asp:Label ID="Label1" class="labelMessage" runat="server" Text="Status:" ></asp:Label>
                    </asp:LinkButton> 
                    <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlStatus_OnSelectedIndexChanged" ></asp:DropDownList>

                    <asp:LinkButton class="tblabel" ID="LinkButton2" runat="server" OnClientClick="return false;" >
                        <img src="Images/trans.png" /><asp:Label ID="Label2" class="labelMessage" runat="server" Text="R" ></asp:Label>
                    </asp:LinkButton> 
                    <asp:TextBox ID="txtJobID" runat="server" ></asp:TextBox>
                    <asp:LinkButton class="tbbutton" ID="btnSearchProduct" ToolTip="Click to Search By Job ID" runat="server" OnClick="btnLoadByJobID_OnClick">
                        <img src="Images/search.png" />
                    </asp:LinkButton>
                </td>
                <td align="right">
                    <asp:UpdatePanel ID="updateBookOut" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:LinkButton class="tbbutton" ID="btnBookOut" runat="server" OnClientClick="return confirmBookout();" OnClick="btnBookOut_OnClick" >
                                <img src="Images/creditcard_32.png" /><asp:Label ID="Label3" class="labelMessage" runat="server" Text="Book Out" ></asp:Label>
                            </asp:LinkButton>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PopupContentHolder" runat="server">
    <table width="100%">
        <tr>
            <td style="width:160px">
                <div style="height:555px; overflow:scroll; width:160px">
                    <asp:UpdatePanel ID="updateCust" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <uc:CustList ID="lstCust" runat="server" AllowPaging="false" AllowSelecting="true" AllowSorting="true" 
                                SaveOnCommit="false" Width="100%" > </uc:CustList>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </td>
            <td>
                <div style="height:555px; overflow:scroll">
                    <asp:UpdatePanel ID="updateRepair" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <uc:RepairList ID="lstRepair" runat="server" AllowPaging="true" AllowSelecting="true" AllowSorting="true" 
                                SaveOnCommit="false" PageSize="20" Width="100%" ></uc:RepairList>

                            <asp:Button ID="btnLoadByCustID" runat="server"  OnClick="btnLoadByCustID_OnClick" style="display:none;" />
                            <asp:Button ID="btnLoadAll" runat="server"  OnClick="btnLoadAll_OnClick" style="display:none;" />
                            <asp:Button ID="btnReturnAsUnrepair" runat="server"  OnClick="btnReturnAsUnrepair_OnClick" style="display:none;" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </td>
        </tr>
    </table>
    
    
</asp:Content>
